﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>运行中</title>
    <script language="JavaScript" src="./Comm/JScript.js" type="text/javascript"></script>
    <script type="text/javascript" src="./Scripts/bootstrap/js/jquery.min.js"></script>
    <script type="text/javascript" src="./Scripts/bootstrap/js/bootstrap.min.js"></script>
    <script src="./Scripts/QueryString.js" type="text/javascript"></script>
    <script src="./Scripts/config.js" type="text/javascript"></script>
    <link href="../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <base target="_self" />

    <style type="text/css">
        a
        {
            color: #0066CC;
            text-decoration: none;
        }
        a:hover
        {
            color: #0084C5;
            text-decoration: underline;
        }
        table
        {
            font: 12px 宋体, Arial, Verdana;
        }
        .TRSum
        {
            font: 12px 宋体, Arial, Verdana;
        }
        .centerTitle th
        {
            text-align: center;
        }
        .Idx
        {
            font-size: 12px;
            font-family: Vijaya;
        }
    </style>

    <script language="javascript" type="text/javascript">

        function SetImg(appPath, id) {
            document.getElementById(id).src = './Img/Mail_Read.png';
        }

        function GroupBarClick(groupName) {

            var alt = document.getElementById('Img' + groupName).alert;
            var sta = 'block';
            if (alt == 'Max') {
                sta = 'block';
                alt = 'Min';
            } else {
                sta = 'none';
                alt = 'Max';
            }

            document.getElementById('Img' + groupName).src = './Img/' + alt + '.gif';
            document.getElementById('Img' + groupName).alert = alt;

            var i = 0;
            for (i = 0; i <= 600; i++) {

                var row = document.getElementById(groupName + i);

                if (row == null || row == undefined || row.style == null)
                    continue;

                if (sta == 'block') {
                    row.style.display = '';
                } else {
                    row.style.display = sta;
                }
            }
        }

        // 撤销。
        function UnSend(fk_flow, workid, fid) {

            if (window.confirm('您确定要撤销本次发送吗？') == false)
                return;

            //执行撤销.
            $.ajax({
                type: 'post',
                async: true,
                url: Handler + "?DoType=Runing_UnSend&FK_Flow=" + fk_flow + "&WorkID=" + workid + "&FID=" + fid + "&m=" + Math.random(),
                dataType: 'html',
                success: function (data) {
                    if (data.indexOf('err@') == 0) {
                        alert(data);
                        return;
                    }

                    $("#Msg").html(data + " <br> @点击这里<a href='javascript:window.location.href = window.location.href;' >刷新</a>");
                    alert(data);
                    var url = 'MyFlow.htm?FK_Flow=' + fk_flow + '&WorkID=' + workid;
                    window.open(url);
                    window.location.href = window.location.href;
                    return;
                }
            });
        }

        //催办.
        function Press(fk_flow, workid, fid) {

            var msg = window.prompt('请输入催办信息', '该工作因为xxx原因，需要您优先处理.');
            if (msg == null)
                return;

            //执行催办.
            $.ajax({
                type: 'post',
                async: true,
                url: Handler + "?DoType=Runing_Press&Msg=" + msg + "&FK_Flow=" + fk_flow + "&WorkID=" + workid + "&FID=" + fid + "&m=" + Math.random(),
                dataType: 'html',
                success: function (data) {
                    if (data.indexOf('err@') == 0) {
                        alert(data);
                        return;
                    }

                    alert(data);
                    return;
                }
            });
        }

        function WinOpenIt(url) {
            //窗口最大化e
            var scrWidth = screen.availWidth;
            var scrHeight = screen.availHeight;
            var self = window.open(url, '_blank', "resizable=1,scrollbars=yes");
            self.moveTo(0, 0);
            self.resizeTo(scrWidth, scrHeight);
            self.focus();
            return;
        }

        /* ESC Key Down */
        function Esc() {
            if (event.keyCode == 27)
                window.close();
            return true;
        }

        /* 打开表单. */
        function OpenFrm(workid, nodeID, flowNo) {

            //执行催办.
            $.ajax({
                type: 'post',
                async: true,
                url: Handler + "?DoType=Runing_OpenFrm&FK_Node=" + nodeID + "&FK_Flow=" + flowNo + "&WorkID=" + workid + "&m=" + Math.random(),
                dataType: 'html',
                success: function (data) {

                    if (data.indexOf('err@') == 0) {
                        alert(data);
                        return;
                    }

                    if (data.indexOf('url@') == 0) {
                        data = data.replace('url@', '');
                        //window.location.href = data;
                        window.open(data);
                        return;
                    }

                    alert(data);

                }
            });
        }

        //页面启动函数.
        $(function () {

            $("#Msg").html("<img src=./Img/loading.gif />&nbsp;正在加载,请稍后......");

            InitPage();

            $("#Msg").html("");
        });

        //初始化数据.
        function InitPage() {

            //随机串.
            var timeKey = Math.random();

            var idx = 0;

            //初始化表格.
            $.ajax({
                type: 'post',
                async: true,
                url: Handler + "?DoType=Runing_Init&m=" + Math.random(),
                dataType: 'html',
                success: function (data) {

                    data = JSON.parse(data);

                    //生成分组的字符串.
                    var str = "";
                    for (var i = 0; i < data.length; i++) {

                        if (str.indexOf('@' + data[i].FlowName) == -1)
                            str += "@" + data[i].FlowName;

                    }
                    var strs = str.split("@"); //生成数组.

                    var num = 0;
                    var is1 = false;
                    //循环数组.
                    for (var idx = 0; idx < strs.length; idx++) {

                        var groupName = strs[idx];

                        if (groupName == "" || groupName == null)
                            continue;

                        var grouStr = "<tr class=Sum onclick=\"GroupBarClick('" + groupName + "')\" > <th colspan=10 class=Sum > <div style='text-align:left; float:left' > <img src='Style/Min.gif' alert='Min' id='Img" + groupName + "'   border=0 /> " + groupName + "</th> </tr>";
                        $("#Table1 tr:last").after(grouStr);


                        //增加处理.
                        for (var i = 0; i < data.length; i++) {
                            var work = data[i];
                            if (work.FlowName != groupName)
                                continue;

                            var newRow = "";
                            num++;

                            if (is1 == true) {
                                newRow += "<tr bgcolor=AliceBlue id='" + groupName + num + "' >";
                                is1 = false;
                            }
                            else {
                                newRow += "<tr bgcolor=white id='" + groupName + num + "' >";
                                is1 = true;
                            }

                            newRow += "<td>" + num + "</td>";
                            newRow += "<td><a href=\"javascript:OpenFrm('" + work.WorkID + "','" + work.FK_Node + "','" + work.FK_Flow + "')\" ><img src='./Img/Runing.png' width='16px' alt='打开表单'/>" + work.Title + "</a></td>";
                          //  newRow += "<td>" + work.FlowName + "</td>";
                            newRow += "<td>" + work.StarterName + "</td>";
                            newRow += "<td>" + work.DeptName + "</td>";
                            //  newRow += "<td>" + work.FlowStartRDT + "</td>";
                            newRow += "<td>" + work.NodeName + "</td>";
                            newRow += "<td>" + work.RDT + "</td>";

                            var todoEmps = work.TodoEmps;

                            if (todoEmps.indexOf(',') != -1)
                                todoEmps = todoEmps.substring(todoEmps.indexOf(',') + 1);

                            newRow += "<td>" + todoEmps + "</td>";
                            newRow += "<td>";

                            newRow += "<a href=\"javascript:WinOpenIt('WFRpt.htm?FK_Flow=" + work.FK_Flow + "&FID=0&WorkID=" + work.WorkID + "&FK_Node=" + work.FK_Node + "&IsRead=0&T=" + timeKey + "');\" ><img src='./Img/Form.png' border=0 width='16px'/>查看轨迹</a>&nbsp &nbsp &nbsp<a href=\"javascript:UnSend('" + work.FK_Flow + "','" + work.WorkID + "','" + work.FID + "')\"><img src='./Img/Action/UnSend.png' border=0 />撤销</a>";

                            // newRow += "<a href=\"javascript:Press('" + work.FK_Flow + "','" + work.WorkID + "','" + work.FID + "')\"><img src='./Img/Action/Press.png' border=0 />催办</a>";
                            newRow += "</td>";
                            newRow += "</tr>";
                            $("#Table1 tr:last").after(newRow);
                        }
                    }
                    $("#Table1").after("<br><div style='float:left;' >合计:" + data.length + "条</div> ");
                }
            });
        }
    </script>
    <style type="text/css">
        　 body
        {
            font-size: 12px;
        }
        　　.breakLine
        {
            word-break: break-all;
        }
        　　</style>
</head>
<body onkeypress="Esc()">
    <table id="Table1" style="width: 100%; word-break: break-all;">
        <tr>
            <th style="width: 38px;">
                序号
            </th>
            <th style="width: 36%;">
                标题(<font color=red>注:已结束的流程,请到流程查询里找</font>)
            </th>
          <!--  <th>
                流程
            </th>-->
            <th>
                发起人
            </th>
            <th>
                发起部门
            </th>
            <!--<th>申请时间</th>-->
            <th>
                当前节点
            </th>
            <th>
                到达时间
            </th>
            <th>
                当前处理人
            </th>
            <th>
                操作
            </th>
        </tr>
    </table>
    <div id="Msg">
    </div>
</body>
</html>
